'use strict';

const path = require('path')
const gulp = require('gulp')
const runSequence = require('run-sequence')
const del = require('del')
// const runSequence = require('run-sequence')
// const browserSync = require('browser-sync')
// const swPrecache = require('sw-precache')
// const gulpLoadPlugins = require('gulp-load-plugins')
// const output = require('sw-precache').output
// const pagespeed = require('sw-precache').pagespeed
// const pkg = require('./package.json')

// const $ = gulpLoadPlugins();
// const reload = browserSync.reload;


var test = require('./plugin/test')
var gulpmarked = require('./plugin/gulp-markdown-page')

gulp.task('clean', () => del(['.tmp', 'dist/*', '!dist/.git'], {dot: true}))

var markedOp = {
  tplPath: './tpl/markdown.tpl',
  // marked: {
  //   gfm: true,
  //   tables: true,
  //   breaks: false,
  //   pedantic: false,
  //   sanitize: false,
  //   smartLists: true,
  //   smartypants: false
  // }
}

gulp.task('markdown', ['clean'], () => {
  gulp.src(['src/*.md'])
  // .pipe(gulp.dest('dist/markdown'))
  .pipe(gulpmarked(markedOp))
  .pipe(gulp.dest('dist/html'))
  
})

gulp.task('css', () => {
  gulp.src(['assets/css/*.css'])
  .pipe(gulp.dest('dist/html/assets/css'))
})

gulp.task('img', () => {
  gulp.src(['assets/imgs/*.*'])
  .pipe(gulp.dest('dist/html/assets/imgs'))
})

gulp.task('default', function() {
  runSequence('markdown', 'css', 'img')
});

